package com.epam.xml.checker;

import java.io.IOException;

import org.apache.log4j.Logger;
import org.xml.sax.SAXParseException;

public class MyErrorHandler implements org.xml.sax.ErrorHandler {
	private static Logger logger = Logger.getLogger(MyErrorHandler.class);;
	
	public MyErrorHandler() throws IOException {
	}
	
	public void warning(SAXParseException e) {
		logger.warn(getLineAddress(e)+" - "+e.getMessage());
	}
	
	public void error(SAXParseException e) {
		logger.error(getLineAddress(e)+" - "+e.getMessage());
	}
	
	public void fatalError(SAXParseException e) {
		logger.fatal(getLineAddress(e)+" - "+e.getMessage());
	}
	
	private String getLineAddress(SAXParseException e) {
		return e.getLineNumber()+":"+e.getColumnNumber();
	}

}
